package io.gitee.kotle.android.mvvm.mvvminterface

import android.content.res.Resources
import io.gitee.kotle.android.utils.isScreenPortrait

/**
 *
 * 描述：
 *
 * @author jiale.wei
 *
 * 创建时间：2022/4/1 12:55
 *
 */
class ScreenOrientationHelper(private val mvvm: IBaseMvvm) {
    private var lastIsScreenPortrait: Boolean? = null

    fun checkScreenPortrait(resources: Resources) {
        val isScreenPortrait = resources.isScreenPortrait()
        if (isScreenPortrait == lastIsScreenPortrait) {
            return
        }
        lastIsScreenPortrait = isScreenPortrait
        mvvm.onScreenOrientationChange(isScreenPortrait)
        if (isScreenPortrait) {
            mvvm.onScreenOrientationPortrait()
        } else {
            mvvm.onScreenOrientationLandscape()
        }
    }
}